package main

func main() {

	//strsArray := []string{"a", "b", "c"}
	//str := "sssssss"

	//测试用例
	req := "   fly me   to   the moon  "

	//打印测试用例返回结果
	resp := lengthOfLastWord(req)
	println(resp)

}

func lengthOfLastWord(s string) int {
	sLen := len(s)
	count := 0
	meeting := false
	for i := 0; i < sLen; i++ {
		if s[i:i+1] != " " { //探测到第一个不为0
			if meeting == false {
				count = 0
			}
			meeting = true
			count++
		} else {
			meeting = false
		}
	}
	return count
}
